var t = getApp();

Page({
    data: {
        info: {},
        activeName: "first",
        dataList: [],
        isLoadMore: !0,
        page: 1,
        titleName: "感恩奖"
    },
    onLoad: function(t) {
        this.getdata();
    },
    initData: function() {
        this.setData({
            info: {},
            activeName: "first",
            dataList: [],
            isLoadMore: !0,
            page: 1,
            titleName: "感恩奖"
        });
    },
    setTsLoadMore: function(t) {
        this.setData({
            isLoadMore: !t
        });
    },
    getdata: function() {
        var a = this;
        wx.showLoading({
            title: "加载中…"
        });
        var e = t.getNetAddresss("plugin.distribution-appreciation.frontend.controllers.center.index");
        t._postNetWork({
            url: e,
            data: {
                page: 1
            },
            success: function(e) {
                var i = e.data, o = i.result, s = i.msg, n = i.data;
                wx.hideLoading(), o ? (a.setData({
                    info: n.info,
                    dataList: n.list.data
                }), a.setTsLoadMore(a.data.page == n.list.last_page), wx.setNavigationBarTitle({
                    title: n.info.plugin_name || a.data.titleName
                })) : t.tips(s);
            },
            fail: function(t) {
                wx.hideLoading();
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore) {
            var e = this.data.page + 1;
            this.setTsLoadMore(!0);
            var i = t.getNetAddresss("plugin.distribution-appreciation.frontend.controllers.center.index");
            t._postNetWork({
                url: i,
                data: {
                    page: e
                },
                success: function(i) {
                    var o = i.data, s = o.result, n = o.msg, d = o.data;
                    if (s) {
                        var r = a.data.dataList.concat(d.list.data);
                        a.setData({
                            dataList: r,
                            page: e
                        }), a.setTsLoadMore(a.data.page == d.list.last_page);
                    } else t.tips(n);
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else t.tips("没有更多数据了");
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.getMoreData();
    },
    onShareAppMessage: function() {}
});